package ltd.dujiabao.capability.adapter.driven.persistence.capmng.modulespec;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import ltd.dujiabao.capability.adapter.driven.persistence.passthrough.PassThroughService;
import ltd.dujiabao.capability.common.dto.Result;
import ltd.dujiabao.capability.common.exception.BusinessException;
import ltd.dujiabao.capability.domain.capmng.sync.modulespec.ModuleSpec;
import ltd.dujiabao.capability.domain.capmng.sync.modulespec.ModuleSpecRepository;

/**
 * @author : DuJiabao
 * @Project : ddd-capability
 * @Time : 2024/4/11 20:17
 * @Desc :
 */
@Repository
public class ModuleSpecRepositoryImpl implements ModuleSpecRepository {

    @Autowired
    private PassThroughService passThroughService;



    @Override
    public ModuleSpec findModuleSpec(Long devId) {
        Result<ModuleSpecDTO> result = passThroughService.findModuleSpec(devId);
        if (!result.isSuccess()) {
            throw new BusinessException(result.getErrorCode());
        }
        return new ModuleSpec(result.getResult().getModuleSpec());
    }
}
